package com.example.chaindemo.web.chain;

import com.example.chaindemo.provider.validator.data.ValidData;
import org.springframework.core.Ordered;

/**
 * @author PC3
 */
public abstract class AbstractValidator implements Validator<String>, Ordered {

    @Override
    public boolean valid(ValidData<String> data) {
        if (this.enabled()) {
            doValid(data);
        }
        return true;
    }

    /**
     * 校验处理逻辑
     *
     * @param data
     */
    protected abstract void doValid(ValidData<String> data);

    @Override
    public boolean enabled() {
        return true;
    }

    @Override
    public String name() {
        return null;
    }

    @Override
    public int getOrder() {
        return Integer.MAX_VALUE;
    }
}
